-
-
Notifications
You must be signed in to change notification settings - Fork 109
fix: reject Windows file paths in can_parse #957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: reject Windows file paths in can_parse #957
Conversation
if (helpers::is_windows_file_path(input)) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you point us to where in the URL spec this is returning false? Chrome and Safari returns true...
> URL.canParse("file:///C:/path/file.node")
true
> URL.canParse("C:\\path\\file.node")
true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually allowed. https://url.spec.whatwg.org/#file-host-state
If state override is not given and buffer is a Windows drive letter, file-invalid-Windows-drive-letter-host validation error, set state to path state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you apply the same change to URL parser, not the can_parse() method, you'll see that it breaks web-platform tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, instead of rejecting Windows file paths
Is it a healthy method to normalize them with the file:///
protocol ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the library provides is WHATWG URL support. If the result disagrees with your expectations make sure first to check the WHATWG URL specification. If you disagree with it, you should take your concerns with WHATWG.
We may have bugs but a bug is a disagreement with WHATWG.
At a glance this PR appears to break the specification. |
@lemire Thank you for the clear guidance. I understand now that we should follow the WHATWG URL spec strictly. I've opened an issue in WHATWG to discuss the Windows file path handling: whatwg/url#873 I'll keep the library's behavior aligned with the spec while we discuss this in WHATWG. |
I am closing this PR since @mertcanaltin reported the issue to WHATWG. It is understood that if the standard changes, we will reopen such a PR. |
reject Windows file paths in can_parse
I tried to solve this place out : nodejs/node#58578 (comment)